<template>
  <div class="gouwudingdan">
    购物车dingdan
    <div class="span">
      <span v-for="item in shu" :key="item.id" @click="fun($event)">{{item.chi}}</span>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src
import "@/assets/font/iconfont.css";
export default {
  data() {
    return {
      shu: [
        { id: 1, chi: 170 },
        { id: 2, chi: 175 },
        { id: 3, chi: 180 }
      ]
    };
  },
  methods: {
    fun(e) {
      window.console.log(e.target.parentElement.children);
      var arr = Array.from(e.target.parentElement.children);
      arr.map(function(item){
        item.classList.remove("active")
      })
      e.target.classList.add("active");
    }
  }
};
</script>
<style scoped>
.gouwudingdan {
  width: 80%;
  margin: 0px auto;
}
.span {
  display: flex;
}
.span span {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  margin: 1rem 1rem;
  cursor: pointer;
}
.span span.active {
  color: red;
  border: 1px solid red;
}
</style>
